Skip to content

Conversation

nbw
Copy link
Contributor

@nbw nbw commented May 30, 2018

Summary

For sidebar items with no subitems, link directly to the page.

Issue

Hex docs show a "Top" sub header even if there are no other contents. As an example, go to the Phoenix Hex documentation, click Guides then Installation and you'll see something like:

screenshot 2018-05-30 13 49 05

In order to actually view the page, you have to click Top. This feels unnecessary.

Solution

Check if there are any contents in each sidebar item, specifically for:

  • types
  • functions
  • macros
  • callbacks
  • headers

If there are no items link directly to the page.

Screenshots

Currently

screenshot 2018-05-30 13 42 13

current_sidebar

With Top removed

screenshot 2018-05-30 13 44 00

new_sidebar

Testing

Verified by generating docs for the ex_docs repo.

Note

I didn't commit any new dist/app files:

screenshot 2018-05-30 14 04 58

@sourcelevel-bot
Copy link

Hello, @nbw! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

}

function flatten(array) {
return array.reduce(function(a, b){ return a.concat(b);}, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires a space before '}'.

}

function flatten(array) {
return array.reduce(function(a, b){ return a.concat(b);}, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra semicolon.

Read more about it here.

}

function flatten(array) {
return array.reduce(function(a, b){ return a.concat(b);}, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before opening brace.

}

function flatten(array) {
return array.reduce(function(a, b){ return a.concat(b);}, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before function parentheses.

}
}

function flatten(array) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before function parentheses.

if (flatten(nodeItems).length === 0){
return options.fn(this);
} else {
return options.inverse(this);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra semicolon.

Read more about it here.

].filter(Array.isArray);

if (flatten(nodeItems).length === 0){
return options.fn(this);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra semicolon.

Read more about it here.

node.headers
].filter(Array.isArray);

if (flatten(nodeItems).length === 0){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before opening brace.

node.macros,
node.callbacks,
node.headers
].filter(Array.isArray);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra semicolon.

Read more about it here.

node.macros,
node.callbacks,
node.headers
].filter(Array.isArray);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a simpler implementation instead traverse this list of nodeItems and then check that they are null or an empty list? This way we don't need to flatten nor build a very large list only to check its length later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point @josevalim. Refactored to iterate through nodeItems and return true as soon as it detects content. Otherwise, false.

@josevalim josevalim merged commit 362edc7 into elixir-lang:master May 31, 2018
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants